package singleton;

/**
 * @ClassName : hungry
 * @Description : 饿汉（推荐）
 * @Author : gyh
 * @Date: 2021-09-04 17:34
 */
public class hungry {

    private static final hungry instance=new hungry();

    private hungry(){}

    public static hungry getInstance(){
        return instance;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            new Thread(()->{
                System.out.println(hungry.getInstance().hashCode());
            }).start();
        }
    }
}
